import Vue from 'vue'
import Router from 'vue-router'
import Home from '../components/Home.vue'
import Learn from '../components/pages/Learn.vue'
import Todo from '../components/pages/Todo.vue'
import Linker from '../components/pages/Linker.vue'
import UniswapDemo from '../components/pages/learn/UniswapDemo.vue'
import CssHome from '../components/pages/todo/CSS-TODO/CssHome.vue'
import VueHome from '../components/pages/todo/VUE-TODO/VueHome.vue'

Vue.use(Router)

let router =  new Router({
    routes: [
        {
            // 首页
            path: '/',
            name: 'Home',
            component: Home    
        },
        {
            // 教程
            path: '/learn',
            name: 'Learn',
            component: Learn       
        },
        {
            // 实践
            path: '/todo',
            name: 'Todo',
            component: Todo           
        },
        {
            //资源 
            path: '/linker',
            name: 'Linker',
            component: Linker         
        },
        {
            // 教程: Uniswap
            path: '/uniswap',
            name: 'uniswap',
            component: UniswapDemo         
        },
        {
            // 实践: css
            path: '/css',
            name: 'css',
            component: CssHome         
        },
        {
            // 实践: vue
            path: '/vue',
            name: 'vue',
            component: VueHome         
        },
        
    ]
},
) 

//  路由跳转置顶
router.beforeEach((to, from, next) => {    
    // chrome
    document.body.scrollTop = 0
    // firefox
    document.documentElement.scrollTop = 0
    // safari
    window.pageYOffset = 0
    next()
}) 

export default router